import React from 'react';
import { Menu, Icon, Button, Layout } from 'antd';
import { Link } from 'react-router-dom';
const { Sider } = Layout;
const SubMenu = Menu.SubMenu;

export default class SiderMenu extends React.Component {
    constructor () {
        super();
        this.state = {
            collapsed: false,
        };
    }
    toggle () {
        this.setState({
            collapsed: !this.state.collapsed,
        });
    }
    render () {
        const { pathname } = this.props;
        return (
            <Sider
                className='app-sider-menu'
                trigger={null}
                collapsible
                collapsed={this.state.collapsed}
            >
                <div className="toggle-menu">
                    <Icon
                        className="trigger"
                        type={this.state.collapsed ? 'menu-unfold' : 'menu-fold'}
                        onClick={this.toggle.bind(this)}
                    />
                </div>
                <Menu mode='inline' defaultSelectedKeys={[pathname]}>
                    <Menu.Item key='/admin/orderm'>
                        <Link to='/admin/orderm'>
                            <Icon type="solution" />
                            <span>订单管理</span>
                        </Link>
                    </Menu.Item>
                    <Menu.Item key='/admin/goodm'>
                        <Link to='/admin/goodm'>
                            <Icon type="shop" />
                            <span>商品管理</span>
                        </Link>
                    </Menu.Item>
                    <SubMenu key='crm' title={<span><Icon type='appstore' /><span>CRM管理</span></span>}>
                        <Menu.Item key='/admin/shelfm'>
                            <Link to='/admin/shelfm'>货架管理</Link>
                        </Menu.Item>
                    </SubMenu>
                    <SubMenu key='base' title={<span><Icon type='appstore-o' /><span>基础设置</span></span>}>
                        <Menu.Item key='/admin/buildm'>
                            <Link to='/admin/buildm'>大厦管理</Link>
                        </Menu.Item>
                    </SubMenu>
                </Menu>
            </Sider>
        );
    }
}
